
//
//  WSSongCanCell.m
//  FD
//
//  Created by xiaofang wang on 2018/11/6.
//  Copyright © 2018年 ZhiYuan Network. All rights reserved.
//

#import "WSSongCanCell.h"
@interface WSSongCanCell()
//选中、取消选中的图片
@property (weak, nonatomic) IBOutlet UIImageView *selectedIv;
/**删除按钮默认影藏 和 selectedIv frame一样*/
@property (weak, nonatomic) IBOutlet UIButton *deleteBtn;
/**删除按钮*/
@property (weak, nonatomic) IBOutlet UIButton *editBtn;

//地址lb
@property (weak, nonatomic) IBOutlet UILabel *addressLb;
//姓名联系电话
@property (weak, nonatomic) IBOutlet UILabel *nameLb;

@end

@implementation WSSongCanCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.selectionStyle = UITableViewCellSelectionStyleNone; //取消点击样式
    
    //默认影藏
    self.deleteBtn.hidden = YES;
    self.editBtn.hidden = YES;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

- (void)setAddressModel:(MyAddressModel *)addressModel {
    _addressModel = addressModel;
    
    self.addressLb.text = [NSString stringWithFormat:@"%@",addressModel.detail];
    
    
    NSString *xsstr = NSLocalizedString(Home_Man, @"先生");
    NSString *nsStr = NSLocalizedString(Home_Woman, @"女士");
    NSString *sex = [addressModel.sex isEqualToNumber:@(0)] ?  xsstr: nsStr;
    
    self.nameLb.text = [NSString stringWithFormat:@"%@ %@ %@",addressModel.consignee,sex,addressModel.phone];
    
    
    //处理选中选中非选中状态
    if (addressModel.selected) {
        self.selectedIv.image = [UIImage imageNamed:@"selected"];
    }else {
        self.selectedIv.image = [UIImage imageNamed:@"unselected"];
    }
}

#pragma mark - 接口
- (void)updateUIWithIsEdit:(BOOL)isEdit {
    //hidden.YES 隐藏
    self.editBtn.hidden = !isEdit;
    self.deleteBtn.hidden = !isEdit;
}


#pragma mark - 点击事件
//编辑按钮
- (IBAction)clickEditBtnAction:(UIButton *)sender {
    if (self.clickEditBlock) {
        self.clickEditBlock();
    }
}

//删除按钮
- (IBAction)deleteBtnAction:(UIButton *)sender {
    if (self.clickDeleteBlcok) {
        self.clickDeleteBlcok();
    }
}

@end
